Repository navigation
fix(quota): cross-tick memory for the Claude read (#5928) - #10001
Conversation
… + 429 cooldown in the gatherer state file (#5928)
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Fixes #5928 (aggregator side, pm-stack).
What
The quota gatherer is a fresh oneshot every ~15 min, so the Claude fetcher's in-process 429 cooldown + last-good cache reset every tick: every tick paid a fresh usage-endpoint call and no last-good Claude read could ever be retained. This gives the gatherer its own cross-tick memory for the
_clauderead, mirroring the fetcher's design:{ lastGoodEntry, cooldownUntil }inquota-gatherer-state.jsonunder the reserved keyclaudeCrossTick:v1(the state file is a flat string map; the key round-trips through the existing readState/writeState plumbing, and the state write now also fires when only the memory changed).markRetainedmachinery instead of surfacing the fresh failure.cooldownUntil = now + Retry-After(fallback 5 min, cap 60 min) and emit the last-good entry retained when one exists; the bare error surfaces only when no read has ever succeeded.Claude session expired) never engages the cooldown. Scope is the claude run only — other providers' finalize/retention behavior (fix(quota-gatherer): ok-but-null retains last-known (no-data); Command Code explicit ask + plan windows (#5704) #5719) is unchanged.Pure helpers (
parseClaudeCrossTick,serializeClaudeCrossTick,isClaudeRateLimitFailure,retryAfterMsFromFailure,claudeCooldownMs) live insrc/quota-gather-map.tswith unit tests insrc/quota-gather-map.test.ts(7 tests).Seam note, stated plainly: the gatherer's only read is the shared
opencode quotalisting subcommand, which performs its own fetch for all providers at once; the gatherer cannot stop that shared call from happening. What the cooldown governs is the gatherer's consumption of the claude result — during cooldown the fresh claude result is discarded and the persisted last-good is emitted retained, which is the aggregator-side seam the issue's fix shape specifies. A fetcher-side skip would belong to the opencode quota module.Tests
bun test src/quota-gather-map.test.ts— 7 pass (parse/serialize round-trip, 429 classification incl. the session-expired exclusion, Retry-After parsing, fallback/cap math).quota-analytics,meta-renewal,opendesign-renewal,lib-deps): 47 pass, 0 fail.bunx tsc --noEmit: no errors in the touched files (pre-existing errors intest/aa-batches.test.tsare on main too).bun test: 18 failures in unrelated live-source/source-gate suites; verified identical on clean main (stash comparison) — pre-existing, not this change.